﻿using System;

namespace _03_二叉树
{
   class Program
   {
      static void Main(string[] args)
      {
         BiNode node1 = new BiNode(1);
         BiNode node2 = new BiNode(2);
         BiNode node3 = new BiNode(3);
         BiNode node4 = new BiNode(4);
         BiNode node5 = new BiNode(5);
         BiNode node6 = new BiNode(6);
         node1.lchild = node2;
         node1.rchild = node3;
         node2.lchild = node4;
         //node2.rchild = new BiNode(0);
         node3.lchild = node5;
         node3.rchild = node6;
         BiTree bt = new BiTree();
         bt.Head = node1;

         bt.PreOrder_Recursive(elem =>
         {
            Console.Write(elem + " ");
         });
         Console.WriteLine();
         bt.InOrder_Recursive(elem =>
         {
            Console.Write(elem + " ");
         });
         Console.WriteLine();
         bt.PostOrder_Recursive(elem =>
         {
            Console.Write(elem + " ");
         });
         Console.WriteLine();
         bt.PreOrder(elem =>
         {
            Console.Write(elem + " ");
         });
         Console.WriteLine();
         bt.PostOrder(elem =>
         {
            Console.Write(elem + " ");
         });
         Console.WriteLine();
         bt.InOrder(elem =>
         {
            Console.Write(elem + " ");
         });
         Console.WriteLine();
         bt.BFS(elem =>
         {
            Console.Write(elem + " ");
         });
         Console.WriteLine();
         Console.WriteLine($"Depth = {bt.GetDepth()}");
         Console.WriteLine($"MaxDis = {bt.GetMaxDistance()}");
         Console.WriteLine($"IsBST = {bt.IsBST()}");
         Console.WriteLine($"IsFT = {bt.IsFT()}");
         Console.WriteLine($"IsBT = {bt.IsBT()}");
         Console.WriteLine($"IsCT = {bt.IsCT()}");

         //bt.GetAncestor_Recursive(node4, node6);
         string s = BiTree.Serialize(node1);
         BiNode sbt = BiTree.Deserialize(s);

         BiTree.Orikami(3);
      }
   }
}
